package com.iqiyi.pps.epg.core.utils;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by karkarrotxu on 2017/7/24.
 */
public final class ApiVrsRequestUtil {
    //http://live.video.iqiyi.com/live?lc=380374422&lp=1132812623&src=1702633101b340d8917a69cf8a4b8c7c&v=1&uid=2190568487&rateVers=PC_QIYI&t=831&k_uidstpialfue2lbejbgof4ruyj2nbyjmp2f&qdx=n&qdv=3&k_err_retries=0&vf=8259a57e78d63cd4dc213a2feabd4f81
    public static final String BASE_URL = "http://live.video.iqiyi.com/live?k_uidgtzzvy7f4defxriu2jiqcclojibbczdj";
    // public static final String PC_WEB_SRC = "1702633101b340d8917a69cf8a4b8c7c";
    public static final String S_SRC_13 = "03032001010000000000";

    public static final String S_SRC_15 = "02020031010000000000";

    private ApiVrsRequestUtil() {
    }
//
//    public static void main(String[] args) {
//        System.out.print(doQuery(380374422l, 1132812623l));
//    }

    public static String getVrsUrl(long channelQipuId, long programQipuId,String platSrc) {
        Map<String, String> map = new HashMap<>();
        map.put("lc", "" + channelQipuId);
        map.put("lp", "" + programQipuId);
        map.put("src", platSrc);
        map.put("v", "1");
        map.put("uid", "1351697526");
        //    map.put("rateVers", "PC_QIYI");
        map.put("t", (System.currentTimeMillis() % 100) + "");
        map.put("k_err_retries", "0");
        map.put("k_test", "1");
        map.put("k_ft1", "64");
        StringBuffer buffer = new StringBuffer(BASE_URL);
        for (Map.Entry<String, String> entry : map.entrySet()) {
            buffer.append("&" + entry.getKey() + "=" + entry.getValue());
        }
        return buffer.toString();
    }

    public static JSONObject doQuery(String buildVrsUrl) {
        JSONObject jsonObject = ApiHttpRequestUtil.getMethod(buildVrsUrl, null, null);
        return jsonObject;
    }

//    public static JSONObject doQuery(long channelQipuId, long programQipuId,String platSrc) {
//        JSONObject jsonObject = ApiHttpRequestUtil.getMethod(getVrsUrl(channelQipuId, programQipuId,platSrc), null, null);
//        return jsonObject;
//    }
}
